import { resolve } from "path";
import { defineConfig } from "vite";
import tailwindcss from "@tailwindcss/vite";

export default defineConfig({
    root: "./src/",
    base: "./",
    server: {
        open: true,
        port: 3000,
    },
    resolve: {
        extensions: [".js", ".vue", ".scss"],
    },
    plugins: [tailwindcss()],
    build: {
        outDir: resolve(__dirname, "./build"),
        emptyOutDir: true,
        rollupOptions: {
            output: {
                chunkFileNames: "js/[name].js",
                entryFileNames: "js/[name]-[hash].js",
                assetFileNames: (asset) => {
                    if (asset.name.includes(".css")) {
                        return "style/[name]-[hash].css";
                    } else {
                        return "assets/[name].[ext]";
                    }
                },
            },
        },
    },
});
